package com.code2roc.xhood.asm;

import com.code2roc.xhood.model.ObsureEnum;
import com.code2roc.xhood.util.ObscureUtil;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;

import java.util.LinkedHashMap;

public class FiledAnnotationAdapter extends AnnotationVisitor {
    private String className;

    public FiledAnnotationAdapter(AnnotationVisitor annotationVisitor) {
        super(Opcodes.ASM9);
        av = annotationVisitor;
    }

    @Override
    public void visit(String name, Object value) {
        this.className = name.replace('/', '.');
        super.visit(name, value);
    }

    @Override
    public void visitEnum(String name, String descriptor, String value) {
        if (value != null) {
            value = ObscureUtil.getObscureNameV3(className,value, ObsureEnum.Field);
        }
        super.visitEnum(name, descriptor, value);
    }

}
